import (
	"blockchain/crypto/sha3pool"
	"encoding/hex"
	"fmt"
)

func analysis() {
	bhByte := []byte{
		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //Version 1
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //Height 0

		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //PreviousBlockId 0000000000000000000000000000000000000000000000000000000000000000
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //PreviousBlockId 0000000000000000000000000000000000000000000000000000000000000000
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //PreviousBlockId 0000000000000000000000000000000000000000000000000000000000000000
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //PreviousBlockId 0000000000000000000000000000000000000000000000000000000000000000

		0xe5, 0x5a, 0x68, 0x5a, 0x00, 0x00, 0x00, 0x00, //Timestamp 1516788453

		0x23, 0x7b, 0xf7, 0x7d, 0xf5, 0xc3, 0x18, 0xdf, //TransactionsRoot 237bf77df5c318dfa1d780043b507e00046fec7f8fdad80fc39fd8722852b27a
		0xa1, 0xd7, 0x80, 0x04, 0x3b, 0x50, 0x7e, 0x00, //TransactionsRoot 237bf77df5c318dfa1d780043b507e00046fec7f8fdad80fc39fd8722852b27a
		0x04, 0x6f, 0xec, 0x7f, 0x8f, 0xda, 0xd8, 0x0f, //TransactionsRoot 237bf77df5c318dfa1d780043b507e00046fec7f8fdad80fc39fd8722852b27a
		0xc3, 0x9f, 0xd8, 0x72, 0x28, 0x52, 0xb2, 0x7a, //TransactionsRoot 237bf77df5c318dfa1d780043b507e00046fec7f8fdad80fc39fd8722852b27a

		0x53, 0xc0, 0xab, 0x89, 0x6c, 0xb7, 0xa3, 0x77, //TransactionStatusHash 53c0ab896cb7a3778cc1d35a271264d991792b7c44f5c334116bb0786dbc5635
		0x8c, 0xc1, 0xd3, 0x5a, 0x27, 0x12, 0x64, 0xd9, //TransactionStatusHash 53c0ab896cb7a3778cc1d35a271264d991792b7c44f5c334116bb0786dbc5635
		0x91, 0x79, 0x2b, 0x7c, 0x44, 0xf5, 0xc3, 0x34, //TransactionStatusHash 53c0ab896cb7a3778cc1d35a271264d991792b7c44f5c334116bb0786dbc5635
		0x11, 0x6b, 0xb0, 0x78, 0x6d, 0xbc, 0x56, 0x35, //TransactionStatusHash 53c0ab896cb7a3778cc1d35a271264d991792b7c44f5c334116bb0786dbc5635

		0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x20, // Bits 2305843009222082559

		0x10, 0x55, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, //Nonce 4216080
	}

	hash1 := [32]byte{}
	sha3pool.Sum256(hash1[:], bhByte[:]) //sha3 256

	/*fisrt hash
	[
		0x89, 0x66, 0x1b, 0x86, 0x6e, 0xe1, 0x25, 0xaa,
		0x5d, 0x5d, 0x63, 0xbf, 0x29, 0x4d, 0xb8, 0x13,
		0x11, 0xbc, 0xe6, 0x1e, 0x3f, 0x18, 0x8c, 0x89,
		0x53, 0x64, 0x12, 0xce, 0xf8, 0xed, 0xa2, 0x7f,
	]*/

	finalByte := []byte{
		0x65, 0x6e, 0x74, 0x72, 0x79, 0x69, 0x64, 0x3a, //string "entryid:"
		0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, //string "blockheader"
		0x3a, //string ":"

		0x89, 0x66, 0x1b, 0x86, 0x6e, 0xe1, 0x25, 0xaa, //hash1 bytes
		0x5d, 0x5d, 0x63, 0xbf, 0x29, 0x4d, 0xb8, 0x13, //hash1 bytes
		0x11, 0xbc, 0xe6, 0x1e, 0x3f, 0x18, 0x8c, 0x89, //hash1 bytes
		0x53, 0x64, 0x12, 0xce, 0xf8, 0xed, 0xa2, 0x7f, //hash1 bytes
	}

	hash2 := [32]byte{}
	sha3pool.Sum256(hash2[:], finalByte[:])
	//hash2 is 70d3756a2a6cf102aff4de29f1a3efada8815757df7f561c2902c29b5372e4d3

	fmt.Println("result is:", hex.EncodeToString(hash2[:]))
}